<?php
class hrd_grub_absen_model extends MY_Model {
	var $nama_tabel = 'hrd_grub_absen';
	
	function GetJSON() {
		$ls_sql	= "	SELECT	*
					FROM	".$this->nama_tabel." 
					WHERE	(UPPER(id_grub_absen_pk) LIKE '%".strtoupper(post('keyword'))."%'
							OR UPPER(nama_grub_absen) LIKE '%".strtoupper(post('keyword'))."%'
							OR UPPER(NVL(ket_grub_absen,'')) LIKE '%".strtoupper(post('keyword'))."%')
					ORDER BY ".(post('sort')=='' ? 'id_grub_absen_pk' : post('sort'))." ".(post('order')=='' ? 'asc' : post('order'));
					
					
		return json_encode( $this->paging($ls_sql) );
	}

	function Add($arr_data){
		$this->db->insert($this->nama_tabel, $arr_data);
	}

	function Update($arr_data, $arr_rule){
		$this->db->update($this->nama_tabel, $arr_data, $arr_rule);
	}

	function DeleteSingle($arr_rule) {
		try {
			$this->db->delete($this->nama_tabel, array('id_grub_absen_pk' => $arr_rule['id_grub_absen_pk']));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}

}
?>